<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <style>
    .box {
      width: 200px;
      height: 200px;
      background: greenyellow;
    }

    /* v-enter
v-enter-active
v-enter-to

v-leave
v-leave-active
v-leave-to */

    .fade-enter {
      opacity: 0;
      /* transform:rotate(-360deg); */
    }

    .fade-enter-active {
      transition: all 2s;
      animation: move 2s;
    }

    .fade-enter-to {
      background: red;
    }

    .fade-leave {}

    .fade-leave-active {
      transition: all 2s;
      animation: move 2s reverse;
    }

    .fade-leave-to {
      opacity: 0;
      /* transform:rotate(360deg); */
    }

    @keyframes move {
      25% {
        transform: scale(0.25) rotate(-360deg);
      }

      50% {
        transform: scale(0.5) rotate(-270deg);
      }

      75% {
        transform: scale(0.75) rotate(-180deg);
      }

      100% {
        transform: scale(1) rotate(-90deg);
      }
    }
  </style>
</head>

<body>

  <div id="app">
    <button @click="isShow=!isShow">显示/隐藏</button>

    <transition name="fade" :duration="{ enter: 5000, leave: 8000 }" v-on:before-enter="beforeEnter"
      v-on:after-enter="afterEnter">
      <div class="box" v-show="isShow"></div>
    </transition>


  </div>

  <script>

    const vm = new Vue({
      el: "#app",
      data: {
        isShow: true
      },
      methods: {
        beforeEnter() {
          console.log('before enter')
        },
        afterEnter() {
          console.log('after enter')
        }
      }
    })

  </script>

</body>

</html>